package br.com.pesca.entity;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Entity
@Table(name = "habitat")
public class Habitat implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private long id;

    @OneToMany(mappedBy = "habitat")
    @LazyCollection(LazyCollectionOption.FALSE)
    private Set<Formulario> formulario;

    @Column(name = "habitat")
    private String habitat;

    @Override
    public int hashCode() {
        final int prime = 41;
        int result = 1;
        result = prime * result + ((id == 0) ? 0 : (new Long(id)).hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Habitat other = (Habitat) obj;
        if (id == 0) {
            if (other.id != 0) {
                return false;
            }
        } else if (!(id == other.id)) {
            return false;
        }
        return true;
    }

    /*
     * GETTERS AND SETTERS
     */
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Set<Formulario> getFormulario() {
        return formulario;
    }

    public void setFormulario(Set<Formulario> formulario) {
        this.formulario = formulario;
    }

    public String getHabitat() {
        return habitat;
    }

    public void setHabitat(String habitat) {
        this.habitat = habitat;
    }
}
